import 'package:flutter/material.dart';
import 'package:flutter_yres/tool/constant.dart';
import 'package:flutter_yres/tool/BlankToolBarTool.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CardAddPage extends StatefulWidget {
  CardAddPage({Key key}) : super(key: key);

  @override
  _CardAddPageState createState() => _CardAddPageState();
}

class _CardAddPageState extends State<CardAddPage> {

  final _cardController = TextEditingController(); //
  final _nameController = TextEditingController(); //
  final _cardNumController = TextEditingController(); // 
  // 响应空白处的焦点的Node
  BlankToolBarModel barModel = BlankToolBarModel();
  ScrollController scrollController = ScrollController();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: Text('添加银行帐号'),
        ),
        body: BlankToolBarTool.blankToolBarWidget(context,
            model: barModel,
            body: Container(
                margin: EdgeInsets.fromLTRB(0, kWindowstateHeight, 0, 0),
                height: ScreenUtil.getInstance().setHeight(1334) - kWindowstateHeight - 56,
                child: SingleChildScrollView(
                    controller: scrollController,
                    child: Column(
                      children: <Widget>[
                        Container(
                            child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[
                              createInputText(_cardController,
                                  hint: '',
                                  text: '银行',
                                  obscureText: true,
                                  type: TextInputType.phone),
                                  createInputText(_nameController,
                                  hint: '',
                                  text: '姓名',
                                  obscureText: true,
                                  type: TextInputType.text),
                                  createInputText(_cardNumController,
                                  hint: '',
                                  text: '卡号',
                                  obscureText: true,
                                  type: TextInputType.phone),
                              new Container(
                                  margin: EdgeInsets.fromLTRB(
                                      0.0, ScreenUtil.getInstance().setWidth(20) * 2, 0, 0.0),
                                  width: ScreenUtil.getInstance().setWidth(750) * 0.8,
                                  child: new RaisedButton(
                                      color: Colors.blue,
                                      shape: StadiumBorder(),
                                      child: new Padding(
                                        padding: new EdgeInsets.all(10.0),
                                        child: new Text(
                                          '保存',
                                          style: new TextStyle(
                                              color: Colors.white,
                                              fontSize: 16.0),
                                        ),
                                      ),
                                      onPressed: () {
                                        // _getCheckOld();
                                      })),
                            ])),
                      ],
                    ))))
    );
  }

  //文字 + 输���框
  Widget createInputText(TextEditingController controller,
      {obscureText: false, String hint, String text, TextInputType type}) {
    FocusNode focusNode = barModel.getFocusNodeByController(controller);
    return Padding(
        padding:
            new EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20) * 2, ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20) * 2, 0),
        child: new Stack(
          alignment: new Alignment(1.0, 1.0),
          //statck
          children: <Widget>[
            new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  new Padding(
                    padding: new EdgeInsets.fromLTRB(0.0, 0.0, 5.0, 0.0),
                    child: new Text(text),
                  ),
                  new Container(
                    width: ScreenUtil.getInstance().setWidth(750) * 0.6,
                    child: new TextField(
                        // focusNode: _contentFocusNode,
                        controller: controller,
                        keyboardType: type,
                        decoration: new InputDecoration(
                          border: InputBorder.none,
                          hintText: hint,
                        ),
                        obscureText: obscureText,
                        focusNode: focusNode),
                  ),
                  new IconButton(
                    icon: new Icon(Icons.clear, color: Colors.black45),
                    onPressed: () {
                      controller.clear();
                    },
                  ),
                ]),
            Divider(
              height: 1,
            ),
          ],
        ));
  }
}